Use internal error instead of ProcessError when multiple tests fail
authorNicolas Koch <nioko1337@gmail.com>
Mon, 31 Aug 2015 10:07:50 +0000 (12:07 +0200)
committerNicolas Koch <nioko1337@gmail.com>
Mon, 31 Aug 2015 10:07:50 +0000 (12:07 +0200)
src/bin/bench.rs
src/bin/test.rs
src/cargo/ops/cargo_test.rs
tests/test_cargo_bench.rs

index 932dae3108ff7374af85c1f12211cf4e3e80a0f7..c90bdba2dd02843021f55894a3f619d1fe57f5a4 100644 (file)
@@ -95,10 +95,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     match err {
         None => Ok(None),
         Some(err) => {
-            Err(match err.exit.as_ref().and_then(|c| c.code()) {
-                Some(i) => CliError::new("", i),
-                None => CliError::from_error(Human(err), 101)
-            })
+            Err(CliError::from_error(Human(err), 101))
         }
     }
 }
index ade460165289000a93ed476c8325a31f3494d0c7..424e8519cc316facec803fb934d806b0fcf0ae7a 100644 (file)
@@ -101,10 +101,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     match err {
         None => Ok(None),
         Some(err) => {
-            Err(match err.exit.as_ref().and_then(|e| e.code()) {
-                Some(i) => CliError::new("", i),
-                None => CliError::from_error(Human(err), 101)
-            })
+            Err(CliError::from_error(Human(err), 101))
         }
     }
 }
index 71636b76d1b5270d39d7f4803431df39fbc13295..6c7227cc285e9a8285f0dbb1ab62daaecf9bf7c9 100644 (file)
@@ -4,7 +4,7 @@ use std::path::Path;
 use core::Source;
 use sources::PathSource;
 use ops::{self, ExecEngine, ProcessEngine, Compilation};
-use util::{self, CargoResult, ProcessError, process_error};
+use util::{self, CargoResult, CargoError, internal};
 
 pub struct TestOptions<'a> {
     pub compile_opts: ops::CompileOptions<'a>,
@@ -15,7 +15,7 @@ pub struct TestOptions<'a> {
 #[allow(deprecated)] // connect => join in 1.3
 pub fn run_tests(manifest_path: &Path,
                  options: &TestOptions,
-                 test_args: &[String]) -> CargoResult<Option<ProcessError>> {
+                 test_args: &[String]) -> CargoResult<Option<Box<CargoError>>> {
     let config = options.compile_opts.config;
     let (compile, error) = try!(build_and_run(manifest_path, options, test_args));
 
@@ -36,7 +36,7 @@ pub fn run_tests(manifest_path: &Path,
                       .filter(|t| t.doctested())
                       .map(|t| (t.src_path(), t.name(), t.crate_name()));
 
-    let mut process_errors = match error {
+    let mut errors = match error {
         None => Vec::new(),
         Some(err) => vec![err],
     };
@@ -91,21 +91,18 @@ pub fn run_tests(manifest_path: &Path,
             shell.status("Running", p.to_string())
         }));
         if let Err(e) = ExecEngine::exec(&mut ProcessEngine, p) {
-            process_errors.push(e);
+            errors.push(Box::new(e));
             if !options.no_fail_fast {
                 break
             }
         }
     }
-    if process_errors.is_empty() {
+    if errors.is_empty() {
         Ok(None)
-    } else if process_errors.len() == 1 {
-        Ok(Some(process_errors.pop().unwrap()))
+    } else if errors.len() == 1 {
+        Ok(Some(errors.pop().unwrap()))
     } else {
-        let err = process_error("Multiple tests failed",
-                                None,
-                                process_errors[0].exit.as_ref(),
-                                process_errors[0].output.as_ref());
+        let err = internal("Multiple tests failed");
         Ok(Some(err))
     }
 
@@ -113,7 +110,7 @@ pub fn run_tests(manifest_path: &Path,
 
 pub fn run_benches(manifest_path: &Path,
                    options: &TestOptions,
-                   args: &[String]) -> CargoResult<Option<ProcessError>> {
+                   args: &[String]) -> CargoResult<Option<Box<CargoError>>> {
     let mut args = args.to_vec();
     args.push("--bench".to_string());
 
@@ -128,7 +125,7 @@ pub fn run_benches(manifest_path: &Path,
 fn build_and_run<'a>(manifest_path: &Path,
                      options: &TestOptions<'a>,
                      test_args: &[String])
-                     -> CargoResult<(Compilation<'a>, Option<ProcessError>)> {
+                     -> CargoResult<(Compilation<'a>, Option<Box<CargoError>>)> {
     let config = options.compile_opts.config;
     let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(),
                                                config));
@@ -165,13 +162,10 @@ fn build_and_run<'a>(manifest_path: &Path,
         Ok((compile, None))
     } else if errors.len() == 1 {
         // Just one error occured => we can return it.
-        Ok((compile, Some(errors.pop().unwrap())))
+        Ok((compile, Some(Box::new(errors.pop().unwrap()))))
     } else {
         // Multiple tests failed => Create a more generic error
-        let err = process_error("Multiple tests failed",
-                                None,
-                                errors[0].exit.as_ref(),
-                                errors[0].output.as_ref());
+        let err = internal("Multiple tests failed");
         Ok((compile, Some(err)))
     }
 }
index 9d0123ec6c681888c2c7231675868f26995796e3..5e3b21cad53301a972a7a7488e61c5d481c5aa3f 100644 (file)
@@ -192,7 +192,7 @@ test bench_hello ... ",
 thread '<main>' panicked at 'assertion failed: \
     `(left == right)` (left: \
     `\"hello\"`, right: `\"nope\"`)', src[..]foo.rs:14
-
+[..]
 ")
               .with_status(101));
 });